package com.cmdi.mq.controller;

import com.cmdi.mq.gateway.config.GatewayDynamicRouteService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 动态路由Controller
 * @Author: gaozb
 */
@Slf4j
@RestController
@RequestMapping("/route")
public class GatewayRouteController {
    @Value("${gw.key:abcd}")
    private String key;

    @Autowired
    private GatewayDynamicRouteService gatewayDynamicRouteService;


    @GetMapping("/update")
    public Boolean update(@RequestParam("gwkey") String gwKey) {
        if(gwKey.equals(key)) {
            log.info("updating.....................");
            gatewayDynamicRouteService.notifyChanged();
            return true;
        }
        return false;
    }
}